from flask_wtf import FlaskForm
from wtforms import StringField, widgets, BooleanField,SelectField
from wtforms.validators import DataRequired, Length
from flask_wtf.file import FileField


class GoodsCategoryForm(FlaskForm):
    name = StringField(
        label='分类名称',
        validators=[
            DataRequired(message='请输入分类名称'),
            Length(min=2, max=30, message='分类名称长度在2-32个字符之间')
        ],
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入分类名称'
        }
    )

    parent_id = StringField(
        label='选择父类',
        validators=[
            DataRequired(message='请选择父类'),
        ],
        render_kw={
            'class': 'form-control custom-select',
            'placeholder': '请选择父类'
        }
    )

    sort = StringField(
        label='排序',
        validators=[
            DataRequired(message='请输入排序'),
        ],
        render_kw={
            'class': 'form-control',
            'placeholder': '请输入数字'
        }
    )

    logo = FileField(
        label='分类图片',
        widget=widgets.FileInput(),
        render_kw={
            'class': 'custom-file-input'
        }
    )

    is_nav = BooleanField(
        label='是否显示在导航栏中',
        render_kw={
            'class': 'form-check-input',
            'placeholder':'请选择'
        }
    )